<% @page_title = '電話受付 ＞ 登録' %>
<h1>New reception</h1>

<%= error_messages_for :reception %>

<% form_for(@reception) do |f| %>
  <p>
    <b>Call date</b><br />
    <%= f.date_select :call_date, :use_month_numbers => true %>
  </p>

  <p>
    <b>Notes</b><br />
    <%= f.text_field :notes %>
  </p>

  <p>
    <b>Member</b><br />
    <%= select_tag ('reception_member_id',
            options_from_collection_for_select(@members, 'id', 'name'),
           :name => 'reception[member_id]') %>
  </p>

  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>

<input id="default_member_id" type="hidden" value="<%= @default_member_id %>"/>
<%= link_to 'Back', receptions_path %>

<script>
	$(document).ready(function(){
		var defaultMemberId = $('#default_member_id').attr('value');
		$('#reception_member_id > option').each(function() {
			if (this.value == defaultMemberId) {
				this.selected = true;
				return false;
			}
		});
    });
</script>